package com.crhms.seabow.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.crhms.seabow.entity.Subtitle;
import com.crhms.seabow.entity.Word;
import com.crhms.seabow.repository.WordRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WordService extends ServiceImpl<WordRepository, Word> {

    @Autowired
    public WordRepository wordRepository;

    public List<Word> getWords(Integer lessonId){

        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("lesson_id",lessonId);
        List<Word> words = wordRepository.selectList(wrapper);

        return words;
    }

    public boolean batchInsert(List<Word> words) {

        //wordRepository.insertBatchSomeColumn(words);
        this.saveBatch(words);
        return true;
    }

    public boolean batchUpdate(List<Word> words) {

        //wordRepository.insertBatchSomeColumn(words);
        this.saveOrUpdateBatch(words);
        return true;
    }

}
